#ifndef __DLOM2_SENSOR_H
#define __DLOM2_SENSOR_H
#include <stdint.h>
#include <stdbool.h>
#define DLOM2_Defalut_Addr 0xf7
#define DLOM2_DEBUG 0
// sensor offset
typedef enum {
	Density_Offset = 2012,
	Temperature_Offset = 2016,
	DynamicViscosity_Offset = 2018,
	KinematicViscosity_Offset = 2082,
	DensitySinglePoint_Offset = 205,
	ViscositySinglePoint_Offset = 208,
	EnterAccessCode = 8646,
	EnterAccessCodeOffset = 2176,
	EnterAccessCodeOffsetNum = 1,

	SinglePointAdjustmentReg = 2510,

	FBUserLevel = 0,
	FBUserLevelOffset = 2179,
	FBUserLevelOffsetNum = 1,

} dlo_m2_holding_reg;

typedef enum {
	SINGLEPOINT_OFF = 0, SINGLEPOINT_WATER = 1,
} dlo_m2_singlepoint_type;

typedef struct dlo_m2_sensor_mdbus {
	uint8_t slave_id;
	uint8_t maintenance_state;
	uint8_t calib_std_den_state;
	uint8_t calib_std_vis_state;
	float densityValue;
	float temperatureValue;
	float dynamicViscosityValue;
	float kinematicViscosityValue;
} dlo_m2_sensor_mdbus_t;

void dlom2_init(uint16_t slave_id);
/// @brief 读取一次值
void dlom2_read_value_poll();

float dlom2_get_density();
float dlom2_get_dynviscosity();
float dlom2_get_kinviscosity();
float dlom2_get_temperature();

void dlom2_set_maintenance();
void dlom2_set_calibration_density_from_slave();
void dlom2_set_calibration_viscosity_from_slave();

void py_f2s4printf(char *stra, float x, uint8_t flen);
void modbus_test();

extern dlo_m2_sensor_mdbus_t dlom2_sensor_value;

#endif
